package com.free.mini.study.controller;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.free.mini.common.base.ResultData;
import com.free.mini.core.server.api.BannerConfigApi;
import com.free.mini.core.server.vo.req.BannerConfigQueryReqVO;
import com.free.mini.core.server.vo.resp.BannerConfigQueryRespVO;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * banner Controller
 *
 * @author dongsufeng
 * @date 2023-08-22 15:17:42
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("api/study/banner/v1/")
public class BannerConfigController {

    private final BannerConfigApi bannerConfigApi;


    @PostMapping("list")
    public ResultData<List<BannerConfigQueryRespVO>> bannerConfigList(@RequestBody @Validated BannerConfigQueryReqVO reqVO) {
        reqVO.setPageIndex(0);
        reqVO.setPageSize(3);
        ResultData<Page<BannerConfigQueryRespVO>> pageResultData = bannerConfigApi.bannerConfigList(reqVO);
        if (pageResultData.isSuccess()){
            return ResultData.data(pageResultData.getData().getRecords());
        }
        return ResultData.error(pageResultData.getCode(),pageResultData.getMessage());
    }
}
